import zipfile
import rarfile


def extract_archive(archive_path, extract_path):
    file_extension = archive_path.split('.')[-1]

    if file_extension == 'zip':
        with zipfile.ZipFile(archive_path, 'r') as zip_ref:
            zip_ref.extractall(extract_path)

    elif file_extension == 'rar':
        with rarfile.RarFile(archive_path, 'r') as rar_ref:
            rar_ref.extractall(extract_path)

    else:
        raise ValueError("Unsupported file format.")

    return extract_path
